home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / VB42VB3.ZIP / UTILS.BAS < prev    next >
Encoding:
BASIC Source File  |  1996-02-22  |  1.7 KB  |  79 lines

  1. Option Explicit
  2.  
  3. ' utils
  4.  
  5. Sub CenterForm (f As Form)
  6.     f.Top = (Screen.Height - f.Height) / 2
  7.     f.Left = (Screen.Width - f.Width) / 2
  8. End Sub
  9.  
  10. Function GetFilename$ (sPath$)
  11.     On Error Resume Next
  12.     Dim ss$, i%, sF$
  13.     i = InStr(sPath, "\")
  14.     If i = 0 Then
  15.         sF = sPath
  16.     Else
  17.         ss = strReverse(sPath)
  18.         i = InStr(ss, "\")
  19.         sF = Mid(sPath, 2 + Len(sPath) - i)
  20.     End If
  21.     GetFilename = sF
  22. End Function
  23.  
  24. Sub MakeFilePath (s$, sDrive$, sPath$, sFile$)
  25.     On Error Resume Next
  26.     Dim i%, j%, s1$
  27.  
  28.     sDrive$ = "": sPath$ = "": sFile$ = ""
  29.     s1 = s
  30.  
  31.     If Mid(s1, 2, 1) = ":" Then ' Drive
  32.         sDrive$ = Mid(s1, 1, 2)
  33.         s1 = Mid(s1, 3)
  34.     End If
  35.  
  36.     i = 0: j = 1
  37.     Do While j > 0
  38.         j = InStr(i, s1, "\")
  39.         If j > 0 Then i = j + 1
  40.     Loop
  41.  
  42.     sPath$ = Mid(s1, 1, i - 1)
  43.     If sPath$ = "\" Then sPath$ = ""
  44.  
  45.     sFile$ = Trim(Mid(s1, i))
  46.  
  47.     Err = 0
  48. End Sub
  49.  
  50. Function MakePath$ (sPath$, sCurPath$)
  51.     On Error Resume Next
  52.     Dim s$, sp$, ss$, i%, iMore%
  53.     s = Trim(sCurPath)
  54.     If Mid(s, Len(s), 1) = "\" Then s = Left(s, Len(s) - 1)
  55.     sp = Trim(sPath)
  56.     If Mid(sp, 2, 1) = ":" Then
  57.         MakePath = sp
  58.     Else
  59.         Do While Left(sp, 2) = ".."
  60.             sp = Mid(sp, 4)
  61.             ss = strReverse(s)
  62.             i = InStr(ss, "\")
  63.             s = Left(s, Len(s) - i)
  64.         Loop
  65.         MakePath = s & "\" & sp
  66.     End If
  67. End Function
  68.  
  69. Function strReverse (s$)   ' LISP
  70.     On Error Resume Next
  71.     Dim sTmp$, i%
  72.     sTmp = ""
  73.     For i = Len(s) To 1 Step -1
  74.         sTmp = sTmp & Mid(s, i, 1)
  75.     Next i
  76.     strReverse = sTmp
  77. End Function
  78.  
  79.